package com.itgaoshu.hospitalproject.service.impl;

import com.itgaoshu.hospitalproject.bean.Menu;
import com.itgaoshu.hospitalproject.bean.User;
import com.itgaoshu.hospitalproject.mapper.MenuMapper;
import com.itgaoshu.hospitalproject.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MenuServiceImpl implements MenuService {

    @Autowired
    private MenuMapper menuMapper;

    public List<Menu> selectMenuAllList(Menu menu) {
        return menuMapper.selectMenuAllList(menu);
    }

    public int addMenu(Menu menu) {
        return menuMapper.addMenu(menu);
    }

    public int deleteMenu(int id) {
        return menuMapper.deleteMenu(id);
    }

    public int updateMenu(Menu menu) {
        return menuMapper.updateMenu(menu);
    }

    public int checkMenuHasChildren(int pid) {
        return menuMapper.checkMenuHasChildren(pid);
    }

    //登录的方法
    @Override
    public User login(String loginname) {
        return menuMapper.login(loginname);
    }

    //根据用户id来查询菜单
    @Override
    public List<Menu> selectMenuById(Integer userid) {
        return menuMapper.selectMenuById(userid);
    }
}
